import pymysql


def modify():
    host = "ring1"
    port = 3306
    db = "movie_analysis"
    username = "root"
    password = "root"

    connect = pymysql.connect(host=host, port=port, db=db, user=username, password=password)
    cursor = connect.cursor()

    sql = "select id, actor from movies"
    update = "update movies set actor=%s where id=%s"

    cursor.execute(sql)
    info = cursor.fetchall()
    for each in info:
        actors = each[1].split('/')
        print(actors)
        if actors[0] == actors[1]:
            actors = actors[1:]
            actor = actors[0]
            for i in actors[1:]:
                actor = actor + "/" + i
            cursor.execute(update, (actor, each[0]))
            connect.commit()
            print(actor)

if __name__ == '__main__':
    modify()